package git.jas0nch.boottest.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

/**
 * projectName : boottest
 * className: LoginController
 * description: TODO 类描述
 *
 * @author : git.jas0nch
 * date: 2022-02-17
 */

@Controller
//@RestController
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@RequestMapping("/user")
public class LoginController {

    @PostMapping("/login")
    public String login(@RequestParam("user") String user, String pwd, Model model, HttpSession session){

        session.setAttribute("loginUser",user);

        model.addAttribute("msg", "{\"user\":\"jason ch\"}");

        return "success";
    }

    @GetMapping("/success")
    public String success(){
        return "success";
    }
}

